/*Replication file for "A Good Partisan? Ideology, Loyalty, and Public Evaluations of Members of Congress" by Geoff Sheagley, Logan Dancey, and John Henderson. Legislative Studies Quarterly*/

//Do file by Logan Dancey

//Replication file to merge 2021 Member Info with 2021 CES Data*/

*Set working directory
cd ""


*Opening 2021 CES
use "CCES21_Common_OUTPUT.dta", clear

***Produce unique identifier statedist variable for merge***

*Code to produce state abbreviations from state names in inputstate variable label 

decode inputstate, gen(statename)

gen stateabb="AL" if statename=="Alabama"
replace stateabb="AK" if statename=="Alaska"
replace stateabb="AZ" if statename=="Arizona"
replace stateabb="AR" if statename=="Arkansas"
replace stateabb="CA" if statename=="California"
replace stateabb="CO" if statename=="Colorado"
replace stateabb="CT" if statename=="Connecticut"
replace stateabb="DE" if statename=="Delaware"
replace stateabb="FL" if statename=="Florida"
replace stateabb="GA" if statename=="Georgia"
replace stateabb="HI" if statename=="Hawaii"
replace stateabb="ID" if statename=="Idaho"
replace stateabb="IL" if statename=="Illinois"
replace stateabb="IN" if statename=="Indiana"
replace stateabb="IA" if statename=="Iowa"
replace stateabb="KS" if statename=="Kansas"
replace stateabb="KY" if statename=="Kentucky"
replace stateabb="LA" if statename=="Louisiana"
replace stateabb="ME" if statename=="Maine"
replace stateabb="MD" if statename=="Maryland"
replace stateabb="MA" if statename=="Massachusetts"
replace stateabb="MI" if statename=="Michigan"
replace stateabb="MN" if statename=="Minnesota"
replace stateabb="MS" if statename=="Mississippi"
replace stateabb="MO" if statename=="Missouri"
replace stateabb="MT" if statename=="Montana"
replace stateabb="NE" if statename=="Nebraska"
replace stateabb="NV" if statename=="Nevada"
replace stateabb="NH" if statename=="New Hampshire"
replace stateabb="NJ" if statename=="New Jersey"
replace stateabb="NM" if statename=="New Mexico"
replace stateabb="NY" if statename=="New York"
replace stateabb="NC" if statename=="North Carolina"
replace stateabb="ND" if statename=="North Dakota"
replace stateabb="OH" if statename=="Ohio"
replace stateabb="OK" if statename=="Oklahoma"
replace stateabb="OR" if statename=="Oregon"
replace stateabb="PA" if statename=="Pennsylvania"
replace stateabb="RI" if statename=="Rhode Island"
replace stateabb="SC" if statename=="South Carolina"
replace stateabb="SD" if statename=="South Dakota"
replace stateabb="TN" if statename=="Tennessee"
replace stateabb="TX" if statename=="Texas"
replace stateabb="UT" if statename=="Utah"
replace stateabb="VT" if statename=="Vermont"
replace stateabb="VA" if statename=="Virginia"
replace stateabb="WA" if statename=="Washington"
replace stateabb="WV" if statename=="West Virginia"
replace stateabb="WI" if statename=="Wisconsin"
replace stateabb="WY" if statename=="Wyoming"
replace stateabb="DC" if statename=="District of Columbia"

*Creating a dash variable
gen dash="-"

*Creating statedist variable
egen statedist=concat(stateabb dash cdid117)
tab statedist

*Merging with Trump Vote
merge m:1 statedist using "2021MemberInfo.dta", generate(_mergeTrumpVote)

//459 not matched from merge -- these members should be missing due to member turnover between vote and CES or lack of voting member

tab statedist if _mergeTrumpVote==1 //shows districts where members didn't merge

tab CurrentHouseName if party==200 & impeach_trump==1 //Shows names of Republican members listed as voting to impeach Trump



